package com.example.rbac.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
//@Aspect
public class TestAop {


    @Pointcut("@annotation(com.example.rbac.aop.Test)")
    public void pointCutName(){
        System.out.println();
    }

    @Before(value = "pointCutName()")
    public void before(JoinPoint joinPoint)throws Exception{
//        JoinPoint.StaticPart staticPart = joinPoint.getStaticPart();
//        com.example.rbac.service.impl.Test aThis = (com.example.rbac.service.impl.Test)joinPoint.getThis();
//        System.out.println(aThis);
        throw new Exception("停止执行");
    }

    @AfterThrowing(value = "pointCutName()")
    public void throwing(JoinPoint joinPoint){
        System.out.println(joinPoint);
    }

    @After(value = "pointCutName()")
    public void after(JoinPoint joinPoint){
        Object target = joinPoint.getTarget();
        System.out.println(target);
    }
}
